﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Reflection;
using System.IO;

namespace WindowsApplication1.jiemian
{
    public partial class Form_encrypt : Form
    {
        public Form_encrypt()
        {
            InitializeComponent();
        }


        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button_pass_Click(object sender, EventArgs e)
        {

            string url = "";

            if (url == "http://qb.qq.com/cgi-bin/qbas_login.cgi")
            {
                string yanzheng = this.textBox_pass1.Text;
                string pass = this.textBox_pass11.Text;

                System.Type type = System.Type.GetTypeFromProgID("MSScriptControl.ScriptControl");
                Object script = System.Activator.CreateInstance(type);
                type.InvokeMember("language", BindingFlags.SetProperty, null, script, new Object[] { "JavaScript" });
                StreamReader sr1 = new StreamReader("ps.js");
                string s = sr1.ReadToEnd();
                type.InvokeMember("AddCode", BindingFlags.InvokeMethod, null, script, new Object[] { s });
                string strtemp = type.InvokeMember("Run", BindingFlags.InvokeMethod, null, script, new Object[] { "hex_hmac_md5", "aR!@$34GP<S#@Js;", pass }).ToString();
                strtemp = yanzheng + strtemp;
                string strtemp1 = type.InvokeMember("Run", BindingFlags.InvokeMethod, null, script, new Object[] { "md5", strtemp }).ToString();
                pass = strtemp1;

                this.textBox_pass2.Text = pass;
            }
            else if (url.IndexOf("https://esales.changyou.com/captcha.xhtml?t=") != -1)
            {
                string yanzheng = this.textBox_pass1.Text;
                string pass = this.textBox_pass11.Text;

                System.Type type = System.Type.GetTypeFromProgID("MSScriptControl.ScriptControl");
                Object script = System.Activator.CreateInstance(type);
                type.InvokeMember("language", BindingFlags.SetProperty, null, script, new Object[] { "JavaScript" });
                StreamReader sr1 = new StreamReader("base64.js");
                string s = sr1.ReadToEnd();
                type.InvokeMember("AddCode", BindingFlags.InvokeMethod, null, script, new Object[] { s });

                //string strtemp22 = type.InvokeMember("Run", BindingFlags.InvokeMethod, null, script, new Object[] { "a", yanzheng }).ToString();

                string strtemp = type.InvokeMember("Run", BindingFlags.InvokeMethod, null, script, new Object[] { "a", yanzheng }).ToString();
                strtemp = strtemp + ",";
                string strtemp1 = type.InvokeMember("Run", BindingFlags.InvokeMethod, null, script, new Object[] { "a", pass }).ToString();
                pass = strtemp + strtemp1 + ",";

                this.textBox_pass2.Text = pass;
            }
        }
    }
}
